import React from "react"
import PropTypes from "prop-types"
import Todo from './Todo'

const TodoList = ({todos,onTodoClick})=>(
    <ul>
        {  console.log(todos)}
        {
            todos.map((item,index)=>(
                <Todo key={item.id} onClick={()=>onTodoClick(item.id)}
                      {...item}
                ></Todo>
            ))
        }
    </ul>
);
TodoList.prototype = {
    todos:PropTypes.arrayOf(PropTypes.shape({
        text:PropTypes.string.isRequired,
        completed:PropTypes.bool.isRequired
    })).isRequired,
    onTodoClick:PropTypes.func.isRequired
}

export default TodoList